<?php

namespace app\common\model;

use think\Model;

use function fast\e;

/**用户申论资源 */
class UserExplaining extends Model
{
    // 表名
    protected $name = 'user_explaining';


    /**购买vip生成申论 */
    public function getSimpleAdd($user_id, $simple_num)
    {
        $info = self::where(['user_id' => $user_id, 'type' => '1'])->find();
        if (empty($info)) {
            # 添加资源
            self::create([
                'user_id' => $user_id,
                'simple_num' => $simple_num,
                'type' => '1',
                'createtime' => time(),
            ]);
        } else {
            $info->simple_num = $info->simple_num + $simple_num;
            $info->updatetime = time();
            $info->save();
        }
        return true;
    }
}
